<!DOCTYPE html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<title>设置</title>
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
		<link rel="stylesheet" type="text/css" href="../../css/aui.css" />

    <style>
			html, body {width: 100%;min-height: 100%;background: #f0f0f0;}
			.h20 {height:0.5rem;background: #f0f0f0;}

      .integral .aui-list-item-title ,.integral .aui-list-item-right {
        color: #999;
        font-size: 0.8rem;
      }
      .integral .color333 {
        color: #333;
      }
      .submit {
        position: fixed;
        bottom: 0;
        left: 0;
        padding: 0 0.75rem;
        text-align: center;
        width: 100%;
      }
      .submit a {
        height: 2.5rem;
        line-height: 2.5rem;
        color: #fff;
        background-color: #2997e4;
        border-radius: 4px;
        width: 100%;
        font-size: 1rem;
        margin: 0 0 1.5rem;
      }
    </style>
</head>
<body>
<div id="app" v-cloak>
  <div class="h20"></div>

  <div class="aui-content aui-margin-b-15">
    <ul class="aui-list aui-form-list">
        <li class="aui-list-item">
            <div class="aui-list-item-inner">
                <div class="aui-list-item-input">
                    <input type="password" placeholder="旧密码" v-model='lodpassword'>
                </div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner">
                <div class="aui-list-item-input">
                    <input type="password" placeholder="新密码" v-model='newpassword'>
                </div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner">
                <div class="aui-list-item-input">
                    <input type="password" placeholder="确认密码" v-model='newspassword'>
                </div>
            </div>
        </li>
    </ul>
</div>

<div class="submit">
  <a href="javascript:;" @click="getCode()">确认修改</a>
</div>
</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
apiready = function() {

	var app = new Vue({
		el: '#app',
		data: {
			lodpassword: '',
			newpassword: '',
			newspassword: '',
			token: ''
		},
		created: function() {
			var $_this = this;
      $_this.token = $api.getStorage('token')
		},
		methods: {
			getCode: function () {
				var $_this = this;
				if($_this.lodpassword == '') {
						api.toast({ msg: '请输入旧密码',duration: 2000,location:'middle' });
					return
				}else if($_this.newpassword == '') {
						api.toast({ msg: '请输入新密码',duration: 2000,location:'middle' });
					return
				} else if($_this.newpassword != $_this.newspassword) {
						api.toast({ msg: '输入的密码不一致',duration: 2000,location:'middle' });
					return
				}
				api.ajax({
					url: window.Url.updatePassword,
					method: 'post',
					headers: {
							'Content-Type': 'application/json',
		          'baseParams': $_this.token //token
					},
					data: {
							body: {
							 oldpassword: $_this.lodpassword,
							 newpassword: $_this.newpassword
							}
					}
				}, function(ret, err) {
						if (ret) {
										api.toast({ msg: ret.message,duration: 2000,location:'middle' });
						} else {
								api.alert({ msg: JSON.stringify(err) });
						}
				});
			}
		}
	})
}
</script>
</html>
